(function () {
    "use strict";

    angular.module('app').service('SysMenuService', SysMenuService);

    SysMenuService.$inject = [
        '$q',
        'A',
        'Api'
    ];

    function SysMenuService($q, A, Api) {

        function getMenus() {
            var defer = $q.defer();
            A.Ajax.get(Api.sys.menu.list)
                .then(function (data) {
                    defer.resolve(data);
                });
            return defer.promise;
        }

        function get(ik) {
            return A.Ajax.get(Api.sys.menu.get(ik));
        }

        function save(sysMenu) {
            return A.Ajax.post(Api.sys.menu.save, sysMenu);
        }

        function remove(ik) {
            return A.Ajax.post(Api.sys.menu.remove(ik));
        }

        return {
            getMenus: getMenus,
            get     : get,
            save    : save,
            remove  : remove
        };
    }
})();